"""
带请求头User-Agent,带参数
1)直接对含有参数的url发起请求
   url = 'https://www.baidu.com/s?wd=python'
2)通过params携带参数字典

"""
import requests

# 百度 搜索 python
# url = 'https://www.baidu.com/s?wd=python'
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
                  "Chrome/86.0.4240.183 Safari/537.36"}
# response = requests.get(url, headers=headers)

# 2)通过params携带参数字典
url = 'https://www.baidu.com/s?'
kw = {'wd': 'python'}
response = requests.get(url, headers=headers, params=kw)

print(response.content.decode())
print(response.request.headers)
print(response.headers)
